package accountinfo.service;

import java.util.Map;

import accountinfo.dao.Transaction;
import accountinfo.dao.TransactionsDAO;

import hackathon1212.GsonFactory;
import hackathon1212.ServletPojoAdapter;

public class CreateTransaction extends ServletPojoAdapter{

	private static final long serialVersionUID = 1866647174385002511L;

	protected Object getBusinessMethod(Map<String, String[]> params) {
		final String [] a = params.get("transaction");
		if(a != null){
			final String json = a[0];
			return TransactionsDAO.save(GsonFactory.get().fromJson(json, Transaction.class));
		} else {
			return TransactionsDAO.save(TransactionsDAO.randomTransaction());
		}
	}
		

}
